package beans;

import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;

@ManagedBean(name = "startBean")
@RequestScoped
public class StartBean {
	private List<SelectItem> ano;
	private String anoSelected;

	private String professorSelected;

	private String linhaPesquisa;

	public StartBean() {
		ano = new ArrayList<SelectItem>();
		for (int i = 2011; i >= 1980; i--) {
			ano.add(new SelectItem("" + i, "" + i));
		}
	}

	public List<SelectItem> getAno() {
		return ano;
	}

	public void setAno(List<SelectItem> ano) {
		this.ano = ano;
	}

	public String getAnoSelected() {
		return anoSelected;
	}

	public void setAnoSelected(String anoSelected) {
		this.anoSelected = anoSelected;
	}

	public String getProfessorSelected() {
		return professorSelected;
	}

	public void setProfessorSelected(String professorSelected) {
		this.professorSelected = professorSelected;
	}

	public String getLinhaPesquisa() {
		return linhaPesquisa;
	}

	public void setLinhaPesquisa(String linhaPesquisa) {
		this.linhaPesquisa = linhaPesquisa;
	}

	public String goToPublication() {
		FacesContext.getCurrentInstance().getExternalContext().getSessionMap()
				.put("professorSelecionado", professorSelected);
		FacesContext.getCurrentInstance().getExternalContext().getSessionMap()
				.put("anoSelecionado", anoSelected);

		return "publicacao";
	}

	public String goToLinhaPesquisa() {

		FacesContext.getCurrentInstance().getExternalContext().getSessionMap()
				.put("linhaPesquisa", linhaPesquisa);
		return "linhaPesquisa";
	}

}
